import React from 'react'
import { useState } from 'react'
import List from './components/List'

//创建一个可以提供数据的上下文对象 然后暴露出去
export const AppContext = React.createContext()

export default function App() {
  const [money, setMoney] = useState(100)
  const changeMoney = () => {
    setMoney(money+1)
  }
  return (
    <div>
      <p>我是父组件</p>
      <p>我有{money}$</p>
      <button onClick={changeMoney}>赚钱了</button>
      <hr />
      <AppContext.Provider value={money}>
        <List />
      </AppContext.Provider>
    </div>
  )
}




